#include "eigen/one_hot_test.h"

#include "eigen/one_hot.h"
#include "log.h"
#include "tools/measure_execution_time.h"

namespace  ldl_eigen
{
void OneHotTest::test()
{
    Eigen::VectorXi labels(10);
    labels << 0, 1, 2, 3, 4, 5, 6, 7, 8, 9;
    auto one_hot_labels = OneHot::encode(labels);
    LogInfo() << "labels: " << labels;
    LogInfo() << "one_hot_labels: " << one_hot_labels;
}

void OneHotTest::performance_test()
{
    Eigen::VectorXi labels(10);
    labels << 0, 1, 2, 3, 4, 5, 6, 7, 8, 9;

    int64_t epochs{1000000};
    Eigen::MatrixXi one_hot_labels{};
    Eigen::VectorXi labels_decode{};
    
    MEASURE_EXECUTION_TIME("CrossEntropyLoss", epochs, {
        one_hot_labels = OneHot::encode(labels);
        labels_decode = OneHot::decode(one_hot_labels);
    });

    MEASURE_CPU_TIME("CrossEntropyLoss", epochs, {
        one_hot_labels = OneHot::encode(labels);
        labels_decode = OneHot::decode(one_hot_labels);
    });
}

}